VAST Challenge 3
With reference to Challenge 3 of VAST Challenge 2022, you are required to reveal the economic of the city of Engagement, Ohio USA by using appropriate static and interactive statistical graphics methods
This exercise requires us to apply the skills you had learned in
Lesson 1 and Hands-on Exercise 1 to reveal the demographic of the city
of Engagement, Ohio USA by using appropriate static statistical graphics
methods. The data should be processed by using appropriate tidyverse
family of packages and the statistical graphics must be prepared using
ggplot2 and its extensions.
Our data includes two csv files from the VAST data source.
p<-ggplot(data=total, aes(x=date, y=remain)) +
geom_bar(stat = "identity", width = 0.5, fill="steelblue") +
coord_cartesian(ylim = c(0, 160)) +
labs(y= 'Total Deposit', x= 'Date',
title = "Fig3. Trend of Living Standards",
subtitle = "Highest remaining in 2022-03") +
geom_text(aes(label = remain), vjust = -1, colour = "black") +
theme(axis.title.y= element_text(angle=90),
axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
axis.ticks.x= element_blank(),
panel.background= element_blank(),
axis.line= element_line(color= 'grey'),
panel.grid.major.y = element_line(color = "grey",size = 0.5,linetype = 2))
ggplotly(p)
# unique(wage$Wage_Group)
#fig <- plot_ly(wage, x = ~wage, fill = ~Wage_Group ,type = "histogram")
#fig
income <- financial %>%
filter(category %in% c('Wage', 'RentAdjustment')) %>%
group_by(participantId) %>%
summarise(income = sum(amount))
outcome <- financial %>%
filter(!category %in% c('Wage', 'RentAdjustment')) %>%
group_by(participantId) %>%
summarise(outcome = sum(abs(amount)))
comparison <- merge(income, outcome, by='participantId') %>%
merge(wage, by='participantId')
comparison$ratio <- comparison$outcome / comparison$income
p <- ggplot(comparison, aes(x = ratio, y = Wage_Group)) +
geom_boxplot()+
labs(y= 'Wage Group', x= 'Ratio in wage',
title = "Fig4: Wage Distribution",
subtitle = "People with low wages tend to spend most of their money")+
#theme_ridges() +
#scale_fill_viridis_d(name = "Quartiles")+
ggtitle("Fig3: Wage Distribution")+
theme(plot.title = element_text(size = 12),
legend.position = "top")
p
outcome_different_cats <- financial %>%
filter(!category %in% c('Wage', 'RentAdjustment')) %>%
group_by(participantId, category) %>%
summarise(outcome = mean(abs(amount))) %>%
merge(wage, by='participantId')
outcome_different_cats$ratio <- outcome_different_cats$outcome / outcome_different_cats$wage
outcome_different_cats$labels <- scales::percent(outcome_different_cats$ratio)
# outcome_different_cats
ggplot(outcome_different_cats,aes(x="", y=outcome, fill=category))+
geom_bar(width = 1, stat = "identity")+
coord_polar("y", start=0)+
scale_fill_brewer(palette="Spectral")+
ggtitle("Category Distribution")+
labs(fill='category')+
xlab("") +
ylab("Participants")+
geom_text(aes(label = labels))